let t = require;
let  e = module
let  o =  e.exports;
 o.default =  e.exports;

                'use strict';
                console.log("start");
                var _n140,
                    i =
                    (this && this.__extends) ||
                    ((_n140 = function n(t, e) {
                            return (_n140 =
                                Object.setPrototypeOf ||
                                ({
                                        __proto__: []
                                    }
                                    instanceof Array &&
                                    function(t, e) {
                                        t.__proto__ = e;
                                    }) ||
                                function(t, e) {
                                    for (var o in e) {
                                        Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                                    }
                                })(t, e);
                        }),
                        function(t, e) {
                            function o() {
                                this.constructor = t;
                            }
                            _n140(t, e),
                                (t.prototype =
                                    null === e ?
                                    Object.create(e) :
                                    ((o.prototype = e.prototype), new o()));
                        });
                Object.defineProperty(o, '__esModule', {
                        value: !0
                    }),
                    (o.ScenePanel = void 0);
                var r = t('UIComponent'),
                    a = t('ResMrg'),
                    s = t('ComUtils'),
                    c = t('SoundMrg'),
                    l = t('AbsScene'),
                    u = t('BattleScene'),
                    h = t('EnemyCtrl'),
                    p = t('AbsInfo'),
                    f = t('SoldierCtrl'),
                    d = t('UIMrg'),
                    g = t('PausePanel'),
                    _ = t('HpBarCom'),
                    y = t('ChapterRoundCfg'),
                    C = t('BattleMrg'),
                    m = t('AbsActor'),
                    v = t('MathUtils'),
                    b = t('UIItemEffect'),
                    M = t('UIMoneyEffect'),
                    I = t('FieldGuidePanel'),
                    A = t('PlayerMrg'),
                    w = t('HurtValueCom'),
                    P = t('LangCfg'),
                    U = (function(t) {
                        function e() {
                            return (null !== t && t.apply(this, arguments)) || this;
                        }
                        return (
                            i(e, t),
                            (e.prototype.onInit = function() {
                                for (var e in (t.prototype.onInit.call(this),
                                        (this._sceneBg = this.view.getComponent(cc.Sprite)),
                                        (this._enemyHpbar = s.default.getComponent(
                                            cc.ProgressBar,
                                            this.view,
                                            'ui/hpBar'
                                        )),
                                        (this._enemyHptxt = s.default.getComponent(
                                            cc.Label,
                                            this.view,
                                            'ui/hpBar/txtLabel'
                                        )),
                                        (this._txtRound = s.default.getComponent(
                                            cc.Label,
                                            this.view,
                                            'ui/txtRound'
                                        )),
                                        (this._btnPause = s.default.getComponent(
                                            cc.Button,
                                            this.view,
                                            'ui/btnPause'
                                        )),
                                        this._btnPause.node.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchPauseHandler,
                                            this
                                        ),
                                        (this._hpBarNode = s.default.getNode(this.view, 'ui/hpbars')),
                                        (this._btnFieldGuide = s.default.getNode(
                                            this.view,
                                            'ui/btnFieldGuide'
                                        )),
                                        this._btnFieldGuide.on(
                                            cc.Node.EventType.TOUCH_END,
                                            this.onTouchFieldGuideHandler,
                                            this
                                        ),
                                        (this._btnFieldGuide.active = !1),
                                        (w.HurtValueCom.HurtValue = s.default.getNode(
                                            this.view,
                                            'HurtValue'
                                        )),
                                        (w.HurtValueCom.HurtValue.parent = null),
                                        A.PlayerMrg.ins.gainBuffs)) {
                                    if (A.PlayerMrg.ins.gainBuffs[e]) {
                                        this._btnFieldGuide.active = !0;
                                        break;
                                    }
                                }
                                this._btnFieldGuide.active ||
                                    A.PlayerMrg.ins.on(
                                        p.InfoEvent.BuffChanged,
                                        this.onBuffChangedHandler,
                                        this
                                    );
                            }),
                            (e.prototype.onLang = function() {
                                if (this._round) {
                                    var t = y.ChapterRoundCfg.ins.getDataByChapter(
                                        this._round.chapterId
                                    );
                                    this._txtRound.string =
                                        P.LangCfg.ins.getContent(201200) +
                                        this._round.round +
                                        '/' +
                                        t.length;
                                }
                            }),
                            (e.prototype.onBuffChangedHandler = function() {
                                (this._btnFieldGuide.active = !0),
                                A.PlayerMrg.ins.off(
                                    p.InfoEvent.BuffChanged,
                                    this.onBuffChangedHandler,
                                    this
                                );
                            }),
                            (e.prototype.onClose = function() {
                                this.removeComs(),
                                    this._soldierCtrl &&
                                    (this._soldierCtrl.destroy(), (this._soldierCtrl = null)),
                                    this._enemyCtrl &&
                                    (this._enemyCtrl.destroy(), (this._enemyCtrl = null)),
                                    this._scene &&
                                    (this._scene.targetOff(this),
                                        this._scene.destroy(),
                                        (this._scene = null)),
                                    this._grids && (this._grids = null),
                                    (this._moneyCom = null);
                            }),
                            (e.prototype.onTouchFieldGuideHandler = function() {
                                c.SoundMrg.click(), d.UIMrg.show(I.FieldGuidePanel);
                            }),
                            (e.prototype.getScope = function() {
                                return this.view.getChildByName('scope');
                            }),
                            Object.defineProperty(e.prototype, 'chapter', {
                                get: function get() {
                                    return this._chapter;
                                },
                                set: function set(t) {
                                    (this._chapter = t),
                                    t
                                        ?
                                        (a.ResMrg.loadSprite(
                                                this._sceneBg,
                                                'Texture/Battle/' + t.res
                                            ),
                                            (this._scene = new u.BattleScene()),
                                            this._scene.on(
                                                l.SceneEvent.AddActor,
                                                this.onAddActorHandler,
                                                this
                                            ),
                                            this._scene.on(
                                                l.SceneEvent.RemoveActor,
                                                this.onRemoveActorHandler,
                                                this
                                            ),
                                            this.view
                                            .getChildByName('scene')
                                            .addChild(this._scene.entity),
                                            (this._soldierCtrl = new f.SoldierCtrl(this._scene)),
                                            this._soldierCtrl.on(
                                                p.InfoEvent.HPChanged,
                                                this.onAllHpChangedHandler,
                                                this
                                            ),
                                            (this._enemyCtrl = new h.EnemyCtrl(this._scene, t)),
                                            this._enemyCtrl.on(
                                                p.InfoEvent.HPChanged,
                                                this.onAllHpChangedHandler,
                                                this
                                            )) :
                                        (this._sceneBg.spriteFrame = null);
                                },
                                enumerable: !1,
                                configurable: !0
                            }),
                            (e.prototype.onAddActorHandler = function(t) {
                                var e = new _.HpBarCom(
                                    cc.instantiate(this.view.getChildByName('HpBar')),
                                    t
                                );
                                e.view.setParent(this._hpBarNode), this.addCom(e);
                            }),
                            (e.prototype.onRemoveActorHandler = function(t) {
                                for (var e = 0; e < this.coms.length; e++) {
                                    var o = this.coms[e];
                                    if (o.actor == t) return void this.removeCom(o);
                                }
                            }),
                            (e.prototype.setGrid = function(t) {
                                this._soldierCtrl && this._soldierCtrl.setGrid(t),
                                    (this._grids = t);
                            }),
                            (e.prototype.setMoneyCom = function(t) {
                                this._moneyCom = t;
                            }),
                            (e.prototype.ready = function(t) {
                                (this._round = t),
                                (this._enemyHpbar.progress = 1),
                                this._soldierCtrl.setRound(t),
                                    this._enemyCtrl.setRound(t),
                                    this.onLang(),
                                    this.onAllHpChangedHandler(this._enemyCtrl);
                            }),
                            (e.prototype.onAllHpChangedHandler = function(t) {
                                1 == t.camp ?
                                    t.hp <= 0 && this.battleOver(!1) :
                                    ((this._enemyHptxt.string = t.hp + '/' + t.hpMax),
                                        cc
                                        .tween(this._enemyHpbar)
                                        .to(0.1, {
                                            progress: t.hp / t.hpMax
                                        })
                                        .start(),
                                        t.hp <= 0 && this.battleOver(!0));
                            }),
                            (e.prototype.startBattle = function() {
                                this._soldierCtrl.start(), this._enemyCtrl.start();
                            }),
                            (e.prototype.battleOver = function(t) {
                                this.emit(C.BattleEvent.BattleOver, t),
                                    t && this.delayCall(1.5, this.dealWithItems);
                            }),
                            (e.prototype.dealWithItems = function() {
                                for (
                                    var t = this._scene.items, e = {}, o = 0; o < t.length; o++
                                ) {
                                    var n = t[o];
                                    if (n.type == m.ActorType.Money)
                                        M.UIMoneyEffect.show(n, this._moneyCom);
                                    else {
                                        var i = this.getEmptyBuffGridItem(e);
                                        i && b.UIItemEffect.show(n, i);
                                    }
                                }
                                this._scene.clearItems();
                            }),
                            (e.prototype.getEmptyBuffGridItem = function(t) {
                                if (this._grids) {
                                    for (var e = [], o = 0; o < this._grids.length; o++) {
                                        for (var n = this._grids[o], i = 0; i < n.length; i++) {
                                            var r = n[i];
                                            (null == r.data || (r.data && r.data.type <= 3)) &&
                                            null == r.buff &&
                                                null == t[r.objId] &&
                                                e.push(r);
                                        }
                                    }
                                    if (e.length > 0) {
                                        var a = e[v.default.randomInt(0, e.length - 1)];
                                        return (t[a.objId] = !0), a;
                                    }
                                }
                                return null;
                            }),
                            (e.prototype.onTouchPauseHandler = function() {
                                c.SoundMrg.click(),
                                    this._scene && this._scene.pause(),
                                    d.UIMrg.show(g.PausePanel, {
                                        type: this._chapter.type,
                                        scene: this._scene
                                    });
                            }),
                            (e.prototype.onUpdate = function(e) {
                                t.prototype.onUpdate.call(this, e),
                                    this._scene && this._scene.update(e),
                                    this._soldierCtrl && this._soldierCtrl.update(e),
                                    this._enemyCtrl && this._enemyCtrl.update(e);
                            }),
                            e
                        );
                    })(r.UIComponent);
                (o.ScenePanel = U), console.log("end");
            module.exports =  e.exports;